#pragma once;

#include "common.h"

#include "contact.h"
#include "collisiondata.h"
#include "rigidbody.h"


namespace TorPhysix
{
	class CollisionPrimitive
	{
	public:
		// Coll Detector needs access to transform to find contact positions
		friend class CollisionDetector;
		RigidBody *body;

		// offset is a translation and rotation that centers the rigid body geometry.
		Mat4f offset;

		// sync CollisionGeometry to Rigid body transform
		void calculateInternals();

		// Get a column in the matrix
		Vec3f getAxis(unsigned int idx) const
		{
			// This does the same job: siut::simd::standard::get( offset, idx ); 
			return Vec3f( transform[idx], transform[idx+4], transform[idx+8] );
		}

		CollisionPrimitive()
		{
			body = new RigidBody; 
		}
		virtual ~CollisionPrimitive()
		{
			delete body;
		}

		
	protected:
		Mat4f transform;
	};

	class CollisionSphere : public CollisionPrimitive
	{
	public:
		CollisionSphere() : CollisionPrimitive()
		{

		}
		virtual ~CollisionSphere()
		{
		}
		// position is not needed, it is the same as the origin of the rigid body
		real radius;
		void scale( Vec3f scaleDelta );
	};

	class CollisionBox : public CollisionPrimitive
	{
	public:
		CollisionBox() : CollisionPrimitive()
		{

		}
		virtual ~CollisionBox()
		{

		}
		Vec3f halfSize;
		void scale( Vec3f scaleDelta );

		const Mat4f& getTransform() const { return transform; }
	};


	// The Plane is not a primitive of a rigid body, it is static. It can only be collided against.
    class CollisionPlane
    {
    public:
        Vec3f direction;
        real offset; // The distance of the plane from the origin.
    };



}